<?php
    $type_content = LoadConfig::$type_content;
    /*$url = new Url();
    $current_url = Common::getCurrentUrl();
    $path_paging = strpos($current_url,'?') !==false ? $current_url.'&' : $current_url.'?';
    $path_paging = str_replace("?page=".$page."&","?",$path_paging);
    $path_paging = str_replace("&page=".$page."&","&",$path_paging);*/
?>
<script src="<?php  echo Yii::app()->params['static_url']; ?>js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="<?php  echo Yii::app()->params['static_url']; ?>js/highcharts.js" type="text/javascript"></script>
<script src="<?php  echo Yii::app()->params['static_url']; ?>js/exporting.js" type="text/javascript"></script>
<script type="">
    $(function () {
        var chart;
        var j2me='<?php echo $data[0]; ?>';           /*echo $data[0];*/
        var android='<?php echo $data[1]; ?>';
        var ios='<?php echo $data[2] ?>';
        var backbery='<?php echo $data[3]; ?>';
        var total='<?php echo $data[4]; ?>';
        var j2me = parseFloat(j2me);
        var android = parseFloat(android);
        var ios = parseFloat(ios);
        var backbery = parseFloat(backbery);
        
        var intJ2me=Math.round(j2me*total/100);
        var intAndroid=Math.round(android*total/100);
        var intIos=Math.round(ios*total/100);
        var intBlackbery=Math.round(backbery*total/100);
        
        $(document).ready(function () {

            // Build the chart
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'chart',
                    plotBackgroundColor: null,
                    plotBorderWidth: 1,
                    plotShadow: true
                },
                title: {
                    text: 'Tổng số người truy cập '+total
                },
                tooltip: {
                    pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                    percentageDecimals: 1
                },

                colors: [
                '#FF0000',
                '#FFFF00',
                '#33FF00',
                '#0033FF'
                ],
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: false
                        },
                        showInLegend: true
                    }
                },
                series: [{
                    type: 'pie',
                    name: 'OS share',
                    data: [
                    ['Android (<b>'+intAndroid+' lượt</b>)',   android],
                    ['IOS (<b>'+intIos+' lượt</b>)',       ios],
                    {
                        name: 'Blackbery (<b>'+intBlackbery+' lượt</b>)',
                        y: backbery,
                        sliced: true,
                        selected: true
                    },
                    ['J2ME (<b>'+intJ2me+' lượt</b>)',    j2me],

                    ]
                }]
            });
        });

    });
</script>
<div id="container">
    <div class="main clearfix">
        <div class="box clearfix bottom30" style="border-bottom:1px solid  #ccc;padding-bottom:10px">
            <form action="" method="get">
                <ul class="form4">
                    
                    <li class="clearfix"><label><strong>Từ ngày </strong>:</label>
                        <div class="filltext">
                            <?php
                                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                'name' => 'from_date',
                                'id' => 'from_date',
                                'value' => $from_date,
                                // additional javascript options for the date picker plugin
                                'options' => array(
                                'showAnim' => 'fold',
                                'dateFormat' => 'dd-mm-yy',
                                'changeYear' => 'true',
                                'changeMonth' => 'true',
                                'showOn' => 'both',
                                'buttonText' => '...'
                                ),
                                'htmlOptions' => array(
                                'style' => 'width:170px',
                                'class' => 'form',
                                ),
                                ));
                            ?> 
                            &nbsp;đến ngày &nbsp; 
                            <?php
                                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                                'name' => 'to_date',
                                'id' => 'to_date',
                                'value' => $to_date,
                                // additional javascript options for the date picker plugin
                                'options' => array(
                                'showAnim' => 'fold',
                                'dateFormat' => 'dd-mm-yy',
                                'changeYear' => 'true',
                                'changeMonth' => 'true',
                                'showOn' => 'both',
                                'buttonText' => '...'
                                ),
                                'htmlOptions' => array(
                                'style' => 'width:170px',
                                'class' => 'form',
                                ),
                                ));
                            ?>  
                        </div>
                    </li>
                    <li class="clearfix"><label><strong>Tài khoản</strong>:</label>
                        <div class="filltext">
                            <input value="<?php if(isset($username)){echo $username;} ?>" type="text" name="username" id="username" style="width: 170px;">
                        </div>
                    </li> 
                    <li class="clearfix"><label><strong>Loại App</strong>:</label>
                        <select name="app_type" style="width:195px;margin-right:14px;height: 25px;">
                        <option value="0">Tất cả</option>
                            <?php foreach($type_content as $key => $value){ ?>
                                <option value="<?php echo $key;?>" <?php echo ($app_type == $key ? 'selected="selected"':'' )?>><?php echo $value?></option>
                                <?php }?>
                        </select>
                    </li>
                    <li class="clearfix"><label>&nbsp;</label>
                        <div class="filltext">
                            <input type="submit" class="btn-bigblue" value=" Tìm kiếm "> 
                        </div>
                    </li>
                    <li>
                        <?php if(!empty($error)) { ?>
                                <div class="err_log txt-left mag-btt10">
                                    <p style="color: red" class="clf60 s14"><strong>Thông báo:</strong> <?php echo $error;?></p>
                                </div>
                            <?php } ?>
                    </li>

                </ul>
            </form>
        </div>
        <?php if(isset($data)){ ?>
        <div class="box">
            <div id="chart" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
        </div>
        <?php } ?>
    </div>
    <!-- End main-->
</div>


